#ifndef CASKMOVECONTROL_H
#define CASKMOVECONTROL_H

#include <QObject>
#include <QWidget>
#include <QPushButton>
#include <QLineEdit>
#include <QLabel>
#include <QGridLayout>
#include <QGroupBox>
#include <QJsonObject>
#include <QDebug>
#include <QRadioButton>
#include <QJsonArray>
#include "flag1control.h"
#include "flag2control.h"
#include "flag3control.h"
#include "tool_pushbutton.h"
#include "flag_lab_cbx.h"
#include "flag_lab_le_lab.h"
#include "flag_ptn_ptn_ptn.h"

#include <QJsonDocument>
#include <QJsonParseError>


#include <QMap>

#include <QMutex>
#include"DeviceManager.h"
#include <QSharedPointer>


// #include <windows.h>
// #include <psapi.h>
class CaskMoveControl : public QWidget
{
    Q_OBJECT
public:
    explicit CaskMoveControl(QWidget *parent = nullptr);
    explicit CaskMoveControl(const QString& Name, const QJsonObject &functionDetails,const QString deviceName, QWidget *parent = nullptr);
    ~CaskMoveControl();
    void createCaskMoveControl(QGroupBox *groupBox, const QJsonObject &functionDetails);
    void updateFlag3ControlSlot(const QJsonObject &jsonData);
public slots:
    // 绑定节点后
    void attachToNode(QSharedPointer<DeviceNode> node);
    void pubMsg(QString content);

private slots:
    void onFlag3AngleChanged(const QString &jointName, double angle,QString command);
    void getFlag3Angles();
    void ctrlInitMsg(const QString& content);
    void onDataReceived(const QString& content);


private:
    QMap<QString, QLineEdit*> lineEditMap;  // 如果你要保存 lineEdit 后续取值

    // 假设在类中有成员变量
    QList<Flag3Control*> flag3Controls;
    QVector<QPair<QString, QString>> flag3Angles;

    QString  currentDevice;
    QString mDeviceID;
    QSharedPointer<DeviceNode> m_node;
    QMutex mCaskMoveCtrlMutex;//互斥鎖
    QMap<QString,QString> initMsg;
    int initCount=0;


signals:
};

#endif // CASKMOVECONTROL_H
